package demo1;

//sealed的应用
sealed class Animals permits Dog{//必须搭配permits，表示可被子类【被final或no-sealed或sealed（含有子类）】继承

}
final class Dog extends Animals{
    //
}
sealed class Animals2 permits Cat,Fish{

}
non-sealed class Cat extends Animals2{
    //non-sealed非密封类表示可被任意子类继承
}
sealed class Fish extends Animals2 permits Fish1{

}
non-sealed class Fish1 extends Fish{

}
//yield与->
public class Test63two {
    public static void main(String[]args){
    String s="a";
    int n=switch (s){

        case"c"-> {
            yield 4;
        }//与下等价
        case"m"->5;//与下面的yield等价
        default -> -1;
    };
    int v=switch (s){
        case"a":
            yield 1;
        case "b":
            yield 2;
        default:
            yield -2;
    };

}}
